﻿@model SMECustomerWebsite.Models.ViewModels.CustomerManager.CustomerPortfolioViewModel

@Html.Action("SubMenuCustomer", "System")
@Html.Action("CustInfo", "System")
<!-- start accordion -->
<div class="">
    <div class="row">
        <div class="col-md-12">
            <div class="x_panel">
                <div class="x_title">
                    <div class="col-lg-8 col-md-9 col-sm-8">
                        <h2>@SMECustomerWebsite.Core.Resources.Resource.Top10Best.ToUpper()</h2>
                    </div>
                    <ul class="nav navbar-right panel_toolbox">
                        @Html.Action("BusinessDateInfo", "System", new { name = "TBL_TOI" })
                        <li>
                            <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                        </li>
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    @switch (Model.CurrentUser.GroupIdentifier)
                    {
                        case "1":
                            <table id="cm-customer-portfolio" class="table custom_table table-bordered table-striped jambo_table">
                                <thead class="headings">
                                    <tr>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.Zone.ToUpper()</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.Branch.ToUpper()</th>
                                        <th class="column-title">DAO</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.MSBONameHeader</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.CifHeader</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.NameHeader</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.IndustryHeader</th>
                                        <th class="column-title">TOI (VND)</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.InfoHeader</th>
                                    </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                            break;
                        case "2":
                        <table id="cm-customer-portfolio" class="table custom_table table-bordered table-striped jambo_table">
                            <thead class="headings">
                                <tr>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.Branch.ToUpper()</th>
                                    <th class="column-title">DAO</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.MSBONameHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.CifHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.NameHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.IndustryHeader</th>
                                    <th class="column-title">TOI (VND)</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.InfoHeader</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                            break;
                        case "3":
                        <table id="cm-customer-portfolio" class="table custom_table table-bordered table-striped jambo_table">
                            <thead class="headings">
                                <tr>
                                    <th class="column-title">DAO</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.MSBONameHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.CifHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.NameHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.IndustryHeader</th>
                                    <th class="column-title">TOI (VND)</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.InfoHeader</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                            break;
                        case "4":
                        <table id="cm-customer-portfolio" class="table custom_table table-bordered table-striped jambo_table">
                            <thead class="headings">
                                <tr>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.CifHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.NameHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.IndustryHeader</th>
                                    <th class="column-title">TOI (VND)</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.InfoHeader</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                            break;
                        default:
                            break;
                    }

                </div>
            </div>
        </div>
    </div>
</div>
<div class="">
    <div class="row">
        <div class="col-md-12">
            <div class="x_panel">
                <div class="x_title">
                    <div class="col-lg-8 col-md-9 col-sm-8">
                        <h2>@SMECustomerWebsite.Core.Resources.Resource.Top10Worst.ToUpper()</h2>
                    </div>
                    <ul class="nav navbar-right panel_toolbox">
                        @Html.Action("BusinessDateInfo", "System", new { name = "TBL_TOI" })
                        <li>
                            <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                        </li>
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    @switch (Model.CurrentUser.GroupIdentifier)
                    {
                        case "1":
                            <table id="cm-top10-worst" class="table custom_table table-bordered table-striped jambo_table">
                                <thead class="headings">
                                    <tr>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.Zone.ToUpper()</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.Branch.ToUpper()</th>
                                        <th class="column-title">DAO</th>
                                        <th class="column-title">MSBO</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.CifHeader</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.NameHeader</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.IndustryHeader</th>
                                        <th class="column-title">TOI</th>
                                        <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.InfoHeader</th>
                                    </tr>
                                </thead>
                                <tbody></tbody>
                            </table>
                            break;
                        case "2":
                        <table id="cm-top10-worst" class="table custom_table table-bordered table-striped jambo_table">
                            <thead class="headings">
                                <tr>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.Branch.ToUpper()</th>
                                    <th class="column-title">DAO</th>
                                    <th class="column-title">MSBO</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.CifHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.NameHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.IndustryHeader</th>
                                    <th class="column-title">TOI</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.InfoHeader</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                            break;
                        case "3":
                        <table id="cm-top10-worst" class="table custom_table table-bordered table-striped jambo_table">
                            <thead class="headings">
                                <tr>
                                    <th class="column-title">DAO</th>
                                    <th class="column-title">MSBO</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.CifHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.NameHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.IndustryHeader</th>
                                    <th class="column-title">TOI</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.InfoHeader</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                            break;
                        case "4":
                        <table id="cm-top10-worst" class="table custom_table table-bordered table-striped jambo_table">
                            <thead class="headings">
                                <tr>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.CifHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.NameHeader</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.IndustryHeader</th>
                                    <th class="column-title">TOI</th>
                                    <th class="column-title">@SMECustomerWebsite.Core.Resources.Resource.InfoHeader</th>
                                </tr>
                            </thead>
                            <tbody></tbody>
                        </table>
                            break;
                        default:
                            break;
                    }

                </div>
            </div>
        </div>
    </div>
</div>
<!-- end of accordion -->
@section scripts
{
    <script type="text/javascript">
        $(document).ready(function () {
            var totalColumn = [
                            { "sName": "CIF", "bSortable": false },
                            { "sName": "NAME", "bSortable": false },
                            { "sName": "VPB INDUSTRY", "bSortable": false },
                            { "sName": "TOI", "bSortable": false },
                            { "sName": "INFO", "bSortable": false }]
            var totalLenCol = 4;
            var totalCifCol = 0;
            var dataSearchTotalMatdt = [{ id: 0, text: 'CIF' }, { id: 1, text: 'Name' }, { id: 2, text: 'VPB Insdustry' }];
            switch (@Model.CurrentUser.GroupIdentifier)
            {
                case 1:
                    totalColumn = [
                           { "sName": "REGION", "bSortable": false },
                           { "sName": "BRANCH", "bSortable": false },
                           { "sName": "DAO", "bSortable": false },
                           { "sName": "MSBO", "bSortable": false },
                            { "sName": "CIF", "bSortable": false },
                            { "sName": "NAME", "bSortable": false },
                            { "sName": "VPB INDUSTRY", "bSortable": false },
                            { "sName": "TOI", "bSortable": false },
                            { "sName": "INFO", "bSortable": false }];
                    totalLenCol = 8;
                    totalCifCol = 4;
                    dataSearchTotalMatdt = [{ id: 3, text: 'Region' }, { id: 4, text: 'Branch' }, { id: 5, text: 'MSBO' }, { id: 0, text: 'CIF' }, { id: 1, text: 'Name' }, { id: 2, text: 'VPB Insdustry' }];
                    break;
                case 2:
                    totalColumn=  [
                        { "sName": "BRANCH", "bSortable": false },
                        { "sName": "DAO", "bSortable": false },
                        { "sName": "MSBO", "bSortable": false },
                            { "sName": "CIF", "bSortable": false },
                            { "sName": "NAME", "bSortable": false },
                            { "sName": "VPB INDUSTRY", "bSortable": false },
                            { "sName": "TOI", "bSortable": false },
                            { "sName": "INFO", "bSortable": false }];
                    totalLenCol = 7;
                    totalCifCol = 3;
                    dataSearchTotalMatdt = [{ id: 4, text: 'Branch' }, { id: 5, text: 'MSBO' }, { id: 0, text: 'CIF' }, { id: 1, text: 'Name' }, { id: 2, text: 'VPB Insdustry' }];
                    break;
                case 3:
                    totalColumn= [
                        { "sName": "DAO", "bSortable": false },
                        { "sName": "MSBO", "bSortable": false },
                            { "sName": "CIF", "bSortable": false },
                            { "sName": "NAME", "bSortable": false },
                            { "sName": "VPB INDUSTRY", "bSortable": false },
                            { "sName": "TOI", "bSortable": false },
                            { "sName": "INFO", "bSortable": false }];
                    totalLenCol = 6;
                    totalCifCol = 2;
                    dataSearchTotalMatdt = [{ id: 5, text: 'MSBO' }, { id: 0, text: 'CIF' }, { id: 1, text: 'Name' }, { id: 2, text: 'VPB Insdustry' }];
                    break;
                default:
                    break;
            }
            var table = $('#cm-customer-portfolio').DataTable({
                "order": [[0, 'asc']],
                "bServerSide": true,
                "bProcessing": true,
                "responsive": true,
                "bAutoWidth": false,
                bFilter: false,
                bInfo: false,
                bPaginate: false,
                "sAjaxSource": '@Url.Action("Top10Data")' + '?type=1',
                "fnServerData": function (sSource, aoData, fnCallback) {
                    $.ajax({
                        "dataType": 'json',
                        "type": "POST",
                        "url": sSource,
                        "data": aoData,
                        "success": fnCallback
                    });
                },
                "sPaginationType": "simple_numbers",//"full_numbers",
                "aoColumns": totalColumn,
                "aoColumnDefs": [{
                    "sClass": "column-title",
                    "aTargets": [totalLenCol],
                    "mRender": function (data, type, full) {
                        return '<a class=\"btn btn-primary btn-xs\" onclick=\"showCustomerInfo(\'' + full[totalCifCol] + '\');\"><i class="fa fa-info"></i></a>';
                    }
                }]
            });
            var tableworst = $('#cm-top10-worst').DataTable({
                "order": [[0, 'asc']],
                "bServerSide": true,
                "bProcessing": true,
                "responsive": true,
                "bAutoWidth": false,
                bFilter: false,
                bInfo: false,
                bPaginate: false,
                "sAjaxSource": '@Url.Action("Top10Data")' + '?type=2',
                "fnServerData": function (sSource, aoData, fnCallback) {
                    $.ajax({
                        "dataType": 'json',
                        "type": "POST",
                        "url": sSource,
                        "data": aoData,
                        "success": fnCallback
                    });
                },
                "sPaginationType": "simple_numbers",//"full_numbers",
                "aoColumns": totalColumn,
                "aoColumnDefs": [{
                    "sClass": "column-title",
                    "aTargets": [totalLenCol],
                    "mRender": function (data, type, full) {
                        return '<a class=\"btn btn-primary btn-xs\" onclick=\"showCustomerInfo(\'' + full[totalCifCol] + '\');\"><i class="fa fa-info"></i></a>';
                    }
                }]
            });
        })
    </script>

}
